using UnityEngine;

namespace TK.Influence
{
    /// <summary>
    /// 大地图上的聚集地类，是所有地图据点的基类
    /// </summary>
    public class Settlement
    {
        /// <summary>
        /// 据点ID
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// 在大地图上的坐标
        /// </summary>
        public Vector2 MapPosition { get; set; }

        /// <summary>
        /// 据点所属的阵营
        /// </summary>
        public Camp OwnedCamp { get;private set; }

        /// <summary>
        /// 据点所拥有的金钱
        /// </summary>
        public int Money { get; set; }

        /// <summary>
        /// 据点所能容纳的最大金钱
        /// </summary>
        public int MoneyMax { get; set; }

        /// <summary>
        /// 据点所拥有的粮草
        /// </summary>
        public int Hay { get; set; }

        /// <summary>
        /// 据点所拥有的最大粮草
        /// </summary>
        public int HayMax { get; set; }

        /// <summary>
        /// 据点所拥有的人口数量
        /// </summary>
        public int Population { get; set; }

        /// <summary>
        /// 据点所能容纳的最大人口
        /// </summary>
        public int PopulationMax { get; set; }

        /// <summary>
        /// 修改据点所属阵营
        /// </summary>
        /// <param name="newOwnedCamp">新的阵营</param>
        public void ChangeCamp(Camp newOwnedCamp)
        {
            // 如果已经是有阵营的据点
            if (OwnedCamp != null)
            {
                // 如果据点在阵营的据点列表中
                if (OwnedCamp.Settlements.Contains(this))
                {
                    OwnedCamp.Settlements.Remove(this);
                }
            }
            // 重新设置据点的所属阵营
            OwnedCamp = newOwnedCamp;
            newOwnedCamp.Settlements.Add(this);
        }

        /// <summary>
        /// 农业值
        /// </summary>
        public int Agricultural { get; set; }

        /// <summary>
        /// 最大农业值
        /// </summary>
        public int AgriculturalMax { get; set; }

        /// <summary>
        /// 商业值
        /// </summary>
        public int Business { get; set; }

        /// <summary>
        /// 最大商业值
        /// </summary>
        public int BusinessMax { get; set; }

        /// <summary>
        /// 民心
        /// </summary>
        public int PopularFeeling { get; set; }

        /// <summary>
        /// 民心最大值
        /// </summary>
        public int PopularFeelingMax { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public void SetFree()
        {
            if (OwnedCamp != null)
            {
                if(OwnedCamp.Settlements.Contains(this)) OwnedCamp.Settlements.Remove(this);
                OwnedCamp = null;
            }
        }


    }
}
